home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 3 / Amiga Format CD03 (1996-07-04)(Future Publishing)(GB)(Track 1 of 6)[!][issue 1996-08].iso / comms / netsoftware / nethandler.lha / NetHandler / handler / volume.c < prev   
C/C++ Source or Header  |  1989-09-16  |  4KB  |  147 lines

  1. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  2. /* |_o_o|\\ Copyright (c) 1987, 1988 The Software Distillery.  All Rights  */
  3. /* |. o.| || Reserved.  This program may not be distributed without the    */
  4. /* | .  | || permission of the authors:                            BBS:    */
  5. /* | o  | ||   John Toebes     Doug Walker    Dave Baker                   */
  6. /* |  . |//                                                                */
  7. /* ======                                                                  */
  8. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  9. /* Volume Manipulation */
  10. /* ActCurentVol  ActRenameDisk ActDiskInfo ActInfo ActDiskChange*/
  11.  
  12. #include "handler.h"
  13.  
  14. static void GetInfo U_ARGS((GLOBAL, struct DosPacket *, struct InfoData *));
  15.  
  16. void ActCurentVol(global, pkt)
  17. GLOBAL global;
  18. struct DosPacket *pkt;              /* a pointer to the dos packet sent    */
  19. {
  20.    BUG(("ActCurentVol\n"));
  21.    pkt->dp_Res1 = MKBADDR(global->volume);
  22. }
  23.  
  24. void ActRenameDisk(global, pkt)
  25. GLOBAL global;
  26. struct DosPacket *pkt;              /* a pointer to the dos packet sent       */
  27. {
  28.    BUG(("ActRenameDisk\n"));
  29.  
  30.    DisMount(global);
  31.    Mount(global, (char *)pkt->dp_Arg1);
  32.  
  33.    pkt->dp_Res1 = DOS_TRUE;
  34. }
  35.  
  36. void GetInfo(global, pkt, info)
  37. GLOBAL global;
  38. struct DosPacket *pkt;
  39. struct InfoData *info;
  40. {
  41.    BUG(("GetInfo\n"));
  42.  
  43.    if(global->volume == NULL)
  44.    {
  45.       info->id_DiskType = ID_NO_DISK_PRESENT;
  46.       pkt->dp_Res1 = DOS_FALSE;
  47.    }
  48.    else
  49.    {
  50.       info->id_NumSoftErrors = global->n.ErrorCount;
  51.       info->id_UnitNumber = global->unitnum;
  52.       if(global->upnodes>1)
  53.       {
  54.          info->id_DiskState = ID_VALIDATED;
  55.          info->id_DiskType  = ID_DOS_DISK;
  56.       }
  57.       else
  58.       {
  59.          info->id_DiskState = ID_VALIDATING;
  60.          info->id_DiskType  = ID_NO_DISK_PRESENT;
  61.       }
  62.       info->id_NumBlocks = global->numnodes;
  63.       info->id_NumBlocksUsed = global->upnodes;
  64.       info->id_VolumeNode = MKBADDR(global->volume);
  65.       info->id_InUse = 0;
  66.       pkt->dp_Res1 = DOS_TRUE;
  67.    }
  68.    BUG(("GetInfo: Exit\n"));
  69. }
  70.  
  71. void ActDiskInfo(global, pkt)
  72. GLOBAL global;
  73. struct DosPacket *pkt;
  74. {
  75.    BUG(("ActDiskInfo\n"));
  76.    GetInfo(global, pkt, (struct InfoData *)pkt->dp_Arg1);
  77. }
  78.  
  79. void ActInfo(global, pkt)
  80. GLOBAL global;
  81. struct DosPacket *pkt;              /* a pointer to the dos packet sent    */
  82. {
  83.    struct FileLock *flock;
  84.    NETPTR nlock;
  85.  
  86.    BUG(("ActInfo\n"));
  87.  
  88.    flock = (struct FileLock *)pkt->dp_Arg1;
  89.  
  90.    if(flock == NULL || flock->fl_Volume != MKBADDR(global->volume) ||
  91.       (nlock=(NETPTR)flock->fl_Key)->RPtr == NULL)
  92.       GetInfo(global, pkt, (struct InfoData *)pkt->dp_Arg2);
  93.    else
  94.    {
  95.       /* It is a remote lock - query the remote fs */
  96.       global->RP.Type = pkt->dp_Type;
  97.       global->RP.Arg1 = (LONG)nlock->RPtr;
  98.       global->RP.DLen = 0;
  99.    
  100.       if(!RemotePacket(global, nlock))
  101.          MQ(global->RP.Data, pkt->dp_Arg2, sizeof(struct InfoData));
  102.    }
  103. }
  104.  
  105. void ActNetKludge(global, pkt)
  106. GLOBAL global;
  107. struct DosPacket *pkt;
  108. {
  109.    struct NetNode *netnode;
  110.    /* Arg1: BPTR to null-terminated BCPL string of name of network node */
  111.    /* Arg2: BPTR to null-terminated string of name of device to use     */
  112.  
  113.    global->RP.Type = ACTION_NETWORK_KLUDGE;
  114.    strcpy(global->RP.Data, (char *)pkt->dp_Arg2);
  115.    global->RP.DLen = strlen((char *)pkt->dp_Arg2);
  116.    if(!(netnode = FindNode(global, (char *)pkt->dp_Arg1+1)) &&
  117.        global->netchain.next)
  118.    {
  119.       BUG(("ActNetKludge: Adding node %s len %d\n", 
  120.          pkt->dp_Arg1+1, (int)*((unsigned char *)pkt->dp_Arg1)));
  121.  
  122.       if(netnode=AddNode(global, 
  123.              (char *)pkt->dp_Arg1, global->netchain.next->ioptr))
  124.          strcpy(netnode->devname, (char *)pkt->dp_Arg2);
  125.    }
  126.    else if(netnode->status != NODE_UP)
  127.       ReSync(global, netnode->ioptr);
  128.  
  129.    if(!netnode || netnode->status != NODE_UP || !netnode->RootLock.RDevice)
  130.    {
  131.       BUG(("ActNetKludge: node %s netnode %08lx unavailable\n", 
  132.          pkt->dp_Arg1, netnode));
  133.       pkt->dp_Res1 = DOS_FALSE;
  134.       pkt->dp_Res2 = ERROR_NODE_DOWN;
  135.    }
  136.    else 
  137.       if(RemotePacket(global, &netnode->RootLock))
  138.          netnode->status = NODE_CRASHED;
  139. }
  140.  
  141. void ActDiskChange(global, pkt)
  142. GLOBAL global;
  143. struct DosPacket *pkt;
  144. {
  145.    BUG(("ActDiskChange\n"));
  146. }
  147.